package com.jwdf.uda.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;

/**
 * 类说明：
 */
public class PromptUtil {
    private static final String HOME_PROMPT = "home";
    private static final String FIND_PROMPT = "find";
    private static final String USER_PROMPT = "user";
    private static final String QUESTION_PROMPT = "question";

    private static final String PREFERENCE_NAME = "promptConfig";

    private static SharedPreferences getSharedPreferences(Context context) {
        return getSharedPreferences(context, PREFERENCE_NAME);
    }

    private static SharedPreferences getSharedPreferences(Context context, String fileName) {
        return context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    }

    public static int getMeasuredWidth(View view) {
        int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        view.measure(w, h);
        return view.getMeasuredWidth();
    }

    public static int getMeasuredHeight(View view) {
        int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        view.measure(w, h);
        return view.getMeasuredHeight();
    }

    public static boolean isShowHomePrompt(Context context) {
        return getSharedPreferences(context).getBoolean(HOME_PROMPT, true);
    }

    public static void setHideHomePrompt(Context context) {
        SharedPreferences.Editor edit = getSharedPreferences(context).edit();
        edit.putBoolean(HOME_PROMPT, false);
        edit.commit();
    }

    public static boolean isShowFindPrompt(Context context) {
        return getSharedPreferences(context).getBoolean(FIND_PROMPT, true);
    }

    public static void setHideFindPrompt(Context context) {
        SharedPreferences.Editor edit = getSharedPreferences(context).edit();
        edit.putBoolean(FIND_PROMPT, false);
        edit.commit();
    }

    public static boolean isShowUserPrompt(Context context) {
        return getSharedPreferences(context).getBoolean(USER_PROMPT, true);
    }

    public static void setHideUserPrompt(Context context) {
        SharedPreferences.Editor edit = getSharedPreferences(context).edit();
        edit.putBoolean(USER_PROMPT, false);
        edit.commit();
    }

    public static boolean isShowQuestionPrompt(Context context) {
        return getSharedPreferences(context).getBoolean(QUESTION_PROMPT, true);
    }

    public static void setHideQuestionPrompt(Context context) {
        SharedPreferences.Editor edit = getSharedPreferences(context).edit();
        edit.putBoolean(QUESTION_PROMPT, false);
        edit.commit();
    }


}
